package com.aizuda.boot.modules.business.feishu.mapper;

import com.aizuda.boot.modules.business.feishu.domain.entity.FeiShuApprovalCode;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 飞书审批定义code Mapper接口
 *
 * @Author sangyirong
 * @ClassName FeiShuApprovalCodeMapper
 * @Version 1.0
 * @Date 2025/8/2 18:15
 */
@Mapper
public interface FeiShuApprovalCodeMapper extends BaseMapper<FeiShuApprovalCode> {

    /**
     * 根据流程key查询飞书审批code列表
     *
     * @param processKey 流程key
     * @return 飞书审批code列表
     */
    @Select("SELECT * FROM feishu_approval_code WHERE process_key = #{processKey}")
    List<FeiShuApprovalCode> selectByProcessKey(@Param("processKey") String processKey);

    /**
     * 根据分类ID、流程key和租户key唯一查询飞书审批code
     *
     * @param categoryId 分类ID
     * @param processKey 流程key
     * @param tenantKey 租户key
     * @return 飞书审批code记录
     */
    @Select("SELECT * FROM feishu_approval_code WHERE category_id = #{categoryId} AND process_key = #{processKey} AND tenant_key = #{tenantKey}")
    FeiShuApprovalCode selectByUniqueKey(@Param("categoryId") Long categoryId, 
                                        @Param("processKey") String processKey, 
                                        @Param("tenantKey") String tenantKey);
}
